import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
// import { userListData } from '/@/api/sys/user';
import { u8SumListData } from '/@/api/bas/u8Sum';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('货位存量选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: 'selIds',
      field: 'selIds',
      component: 'Input',
      show: false,
    },
    {
      label: '仓库',
      field: 'cwhcode',
      component: 'Input',
      show: true,
    },
    {
      label: '货位编码',
      field: 'cposcode',
      component: 'Input',
      show: true,
    },
    {
      label: t('货位名称'),
      field: 'cposname',
      component: 'Input',
    },
    {
      label: t('存货'),
      field: 'cinvcode',
      component: 'Input',
      show: false,
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('仓库'),
    dataIndex: 'cwhcode',
    key: 'cwhcode',
    sorter: true,
    width: 80,
  },
  {
    title: t('区域'),
    dataIndex: 'areacode',
    key: 'areacode',
    sorter: true,
    width: 80,
  },
  {
    title: t('货位编码'),
    dataIndex: 'cposcode',
    key: 'cposcode',
    sorter: true,
    width: 100,
  },
  {
    title: t('货位名称'),
    dataIndex: 'cposname',
    key: 'cposname',
    sorter: true,
    width: 100,
  },
  {
    title: t('存货'),
    dataIndex: 'cinvcode',
    key: 'cinvcode',
    sorter: true,
    width: 130,
  },
  {
    title: t('物料代码'),
    dataIndex: 'cinvaddcode',
    key: 'a.cinvaddcode',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('物料名称'),
    dataIndex: 'cinvname',
    key: 'a.cinvname',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('批次'),
    dataIndex: 'cbatch',
    key: 'cbatch',
    sorter: true,
    width: 100,
  },
  {
    title: t('数量'),
    dataIndex: 'iquantity',
    key: 'iquantity',
    sorter: true,
    width: 100,
  },
];

const tableProps: BasicTableProps = {
  api: u8SumListData,
  beforeFetch: (params) => {
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'id',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'cwhcode',
  itemName: 'cposname',
};
